<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 通知信息</title>
    <meta name="keywords" content="ZDH 通知信息">
    <meta name="description" content="ZDH 通知信息">

    <link rel="shortcut icon" href="img/favicon.ico">
    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>通知信息配置</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                            <i class="fa fa-eye"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="javascript:void(0);" onclick="getResourceDesc()">功能说明</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="ibox-content">
                    <form id="server_form" name="server_form" method="post" class="form-horizontal" action="">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">通知内容</label>
                            <div class="col-sm-10">
                                <input id="msg" name="msg" type="text"
                                       placeholder="通知内容" class="form-control" aria-required="true"> </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">通知类型</label>
                            <div class="col-sm-10">
                                <select id="show_type" name="show_type"
                                        data-placeholder=""
                                        class="chosen-select form-control m-b" tabindex="2">
                                    <option value="1" mytype="">弹框</option>
                                    <option value="2" mytype="">文字</option>
                                    <option value="3" mytype="">不展示</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <div class="text-center">
                                <button id="update_zdh" name="update_zdh" class="btn btn-primary" οnsubmit='return false'
                                        type="button">更新
                                </button>
                                <button id="reset" class="btn btn-white" type=reset>清空</button>
                            </div>
                        </div>


                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="js/zdh_common.js"></script>
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>

<!-- Toastr script -->
<script src="js/plugins/toastr/toastr.min.js"></script>

<script src="js/plugins/chosen/chosen.jquery.js"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>


<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script>

    $(document).ready(function () {

        $('#show_type').chosen();
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });


        $.ajax({
            type: 'POST',
            url: server_context+"/every_day_notice",
            dataType: 'json',
            data: {},
            //成功返回
            success: function (data) {
                if(data.code != '200'){
                    layer.msg(data.msg);
                    return ;
                }
                $('#msg').val(data.result.msg);
                $('#show_type').val(data.result.show_type);
                $('#show_type').trigger("chosen:updated");
            },
            //处理完成
            complete: function () {
                console.info("complete")
            },
            //报错
            error: function (data) {
                console.info("error: " + data.responseText);
            }
        });


        $('#update_zdh').click(function () {

            if ( $('#msg').val() == '') {
                layer.msg("通知信息不能为空！");
                return ;
            }

            $.ajax({
                type: 'POST',
                url: server_context+"/notice_update",
                dataType: 'json',
                data: $("#server_form").serialize(),
                //发送数据前
                beforeSend: function () {
                    // 禁用按钮防止重复提交
                    $("#update_zdh").attr({disabled: "disabled"});
                },
                //成功返回
                success: function (data) {
                    $("#update_zdh").removeAttr('disabled');
                    if(data.code != "200"){
                        layer.msg(data.msg);
                        return ;
                    }
                    layer.msg("更新完成");
                    closeTab()
                },
                //处理完成
                complete: function () {
                    console.info("complete")
                },
                //报错
                error: function (data) {
                    console.info("error: " + data.responseText);
                }
            });


        })

    });
</script>

</body>

</html>
